freecivfandomcom-20200223-history
Introduction tasks
The Freeciv code base can be overwhelming for a new developer. It is large. It is written in more than one programming language. It uses many libraries. It has many different sub systems. It has custom data formats and network protocols. Some changes to Freeciv has to touch many areas. A new developer trying to do it will have to learn them all before seeing the results. This can be extremely discouraging. Other changes to Freeciv are limited to a few areas. They can give results after learning a few things. But a new developer won't know what is what. This page lists tasks that should be achievable with a change that only touch a few areas. Doing an introduction task is intended to be a good introduction to an area of the Freeciv code. Each task lists what you probably will have to learn (unless you already know it). Remember to check that it is doable without having to learn so many new things that you give up. AI: building city action immunity value Your patch will probably be shorter than this post. Skills you must learn/have to do this * Playing Freeciv * Change a rule set (for testing) * Running Freeciv auto games * Compile the Freeciv source code * Get the source code of Freeciv trunk from SVN * A little bit of C coding * Create a patch Background In 2.5 and below it is only possible to protect a city against the incite spy action. From Freeciv 2.6 it is possible to create a rule set that has a building that makes a city immune to actions like poison, steal a tech and establish an embassy. This is done by editing the action enabler(s) (new concept in Freeciv 2.6) of the action you wish the building to block. The Freeciv AI makes some decisions, like what building to build in a city, based on utility. That is a fancy way of saying that it calculates a number to represent how much it wants a particular building and use that number when deciding what to build next. Support for considering action immunity has been added to the evaluation of buildings. The task Your patch will adjust the values representing how bad the AI think it is that one of its cities could become a target of the different actions. The value of incite city may need adjustment too. You can do this in the function action_target_neg_util() in the file ai/default/aicity.c. The goal of adjusting ("balancing") them is to make the AI play better. Your patch should be for the current trunk branch of Freeciv. When this is done post your patch to patch #4623. A back port of your patch is a version of your patch for an older version of Freeciv. Including a back port is nice but not required. There is a risk that your back port won't be used even if the trunk version is used. That risk goes up as the older version becomes more stable. Hints For some actions it is natural to make the value depend on knowledge about the city it self. The city is given in the parameter pcity. You can get a lot of information from it. (Want to know what techs its owner has? Get the owner from the city and get his list of known techs!) It may also be a good idea to consider other rules/settings like diplchance. (The badness of incite use diplchance) You will have to test your changes to know your new values actually are better. Give the new values to the experimental AI level. Let hard AI level keep the old values until you know they are better. Run auto games so you won't have to wait for human players to move. Make sure you have loaded the ruleset you modified before starting to test. Make sure you are running the version of Freeciv you just modified. You don't have to install Freeciv again each time you make a change. The script fcser allows you to run the Freeciv server from the folder where you compiled it. The script fcgui allows you to start a client the same way. To test you changes you will have to modify a rule set. I recommend starting with a copy of the classic ruleset. Action enablers live in the ruleset file game.ruleset. Buildings live in the ruleset file buildings.ruleset. The classic ruleset live in data/classic. To make a building in the target city block an action you must first find all action enablers that enable it. (Classic currently only have one one action enabler for each action) Then find the target_reqs requirement vector. If it don't have one add one. Add the building as a requirement and set present to FALSE. How to create a patch, get Freeciv trunk from SVN and compile Freeciv is documented online. You can find good introductions to C for the programming skill set you already have by using Google. Try to remember reading your patch before sending it to make sure that test data like ruleset modifications wasn't accidentally included. AI: government action immunity value Your patch will probably be shorter than this post. Skills you must learn/have to do this * Playing Freeciv * Change a rule set (for testing) * Running Freeciv auto games * Compile the Freeciv source code * Get the source code of Freeciv trunk from SVN * A little bit of C coding * Create a patch Background The Freeciv AI makes some decisions, like what government to change to, based on utility. That is a fancy way of saying that it calculates a number to represent how good a particular government is and use that number when deciding what to change to. The task Your patch will adjust the values representing how much the AI should value immunity to certain actions even if it doesn't have any cities yet. The value of incite city and bribe unit aren't new but they may need adjustment too. You can do this in the function adv_best_government() in the file server/advisors/advdata.c. The goal of adjusting ("balancing") them is to make the AI play better. Your patch should be for the current trunk branch of Freeciv. Submit your patch to the Freeciv patch tracker when you are done. Hints Would you value government provided immunity to being nuked above immunity to having your city investigated? The values are currently set inside a switch statement. Remember to "break" after setting a value so the value below won't be added. You will have to test your changes. Run auto games. Make sure you are running the version of Freeciv you just modified. To test you changes you will have to modify a rule set. I recommend starting with a copy of the classic ruleset. Action enablers live in the ruleset file game.ruleset. Buildings live in the ruleset file buildings.ruleset. The classic ruleset live in data/classic. To make a government block an action you must first find all action enablers that enable it. Then find the target_reqs requirement vector. If it don't have one add one. Add the government as a requirement, set range to player and present to FALSE. How to create a patch, get Freeciv trunk from SVN and compile Freeciv is documented online. You can find good introductions to C for the programming skill set you already have by using Google. Try to remember reading your patch before sending it to make sure that test data like ruleset modifications wasn't accidentally included. AI: improve spy steal tech selection A step above complete beginner task. Skills you must learn/have to do this *Changing a rule set (for testing) *Running auto games or playing Freeciv (for test games) *Compiling the Freeciv source code *Getting the Freeciv 3.0 (and 2.6) source code from SVN *C coding *Creating a patch Background In Freeciv 2.6 it will be possible to give a unit the ability to steal a specified tech without giving it the ability to steal a random tech. When a spy decides to steal a tech it will currently choose to steal a random tech ("Steal Tech") if that is legal. This improves the probability of success. If stealing a random tech is forbidden it will try to steal the first tech it finds using "Targeted Steal Tech". In the bundled rulesets "Steal Tech" is always legal when "Targeted Steal Tech" is. The task The way choose_tech_to_steal() chooses target tech should be improved. A simple way of doing it is to go for the most expensive tech. A more complex alternative would consider how much the AI wants each tech. (See AI want in Freeciv context or utility in general AI literature) The more complex alternative is more like the rest of the Freeciv AI. If you are extremely confident about the way you select the target tech you can also modify dai_diplomat_city() to go for "Targeted Steal Tech" in some cases where "Steal Tech" is legal. (That would be best to do in a follow up patch) When your patch is ready for review attach it to patch #5767. Hints The choice of what tech to steal is done the function choose_tech_to_steal() in ai/default/aidiplomat.c. The code that always choose to steal a random tech is located in the function dai_diplomat_city(), also located in ai/default/aidiplomat.c. See also the testing hints for AI: building city action immunity value Ruleset: make the civ2 ruleset more like Civilization 2 No C programming required. Skills you must learn/have to do this *Changing a rule set *Playing Freeciv (for test games) *Creating a patch Background The ruleset gets more control as Freeciv evolves. This may make it possible to change the civ2 ruleset so it acts more like Civilization 2. Read Comparison_of_Freeciv's_civ2_modpack_and_Civilization_II for more. The task Change a civ2 rule so it becomes more like Civilization 2. Create a patch. Upload it to Freeciv's patch tracker. Hints See Comparison_of_Freeciv's_civ2_modpack_and_Civilization_II Category:Coding Category:Projects